import {fetch} from './getData.js'
import { Toast } from 'mint-ui'
export default {
  //获取商户菜单类型
  getDishType(params) {
    params = params || {};
    params.method = 'get';
    params.url = '/v2/web/dishType/querylow/' + params.mchtId;
    return fetch(params);
  },
  //获取商户菜单类型
   getScopeType(params) {
        params = params || {};
        params.method = 'get';
        params.url = '/v2/api/dishType/querylow/' + params.mchtId;
        return fetch(params);
    },
  /*
  * 获得商户类型菜单拼凑所需使用字符串,组成数组
  * */
  getScpoeString: async function (data) {
    let typeList = [];
    let typeListResult = await this.getScopeType({mchtId: data.mchtId});
    if(typeListResult.respCode !== "00"){
      Toast({
        message: typeListResult.errorInfo,
        duration: 800
      });
      return ""
    }
    let scpoeList = typeListResult.content.lowTypeNameList;//商户菜单类型名称及id
    data.scpoe.substr(1, data.scpoe.length + 1).split(",").find(
      data => {
        scpoeList.forEach(value => {
          if (value.typeId == data) {
            typeList.push(value.typeName);
          }
        });
      }
    );
    return typeList.join("、") // 返回值为可用或不可用商品名称
  },
  //绑定成为店员
  setBindAccount(params) {
    params = params || {};
    params.method = 'post';
    params.url = '/v3/web/usr/account/' + params.usrId;
    params.data = {
      mchtId: params.mchtId,
      usrAcc: params.usrAcc,
      loginPwd: params.loginPwd
    }
    return fetch(params);
  },
  //获取个人信息
  getUsrInfo(params) {
    params = params || {};
    params.method = 'get';
    params.url = '/v3/web/usr/myInfo/' + params.usrId;
    return fetch(params);
  },
  //   电子券分享朋友请求
  rpCodeToFriend(params) {
    params = params || {};
    params.method = 'post';
    params.url = '/v3/share/circle_of_friends/qr_code';
    return fetch(params);
  },
  //   电子券券码查询,不受条件限制都可查询
  findShareCouponNo(params) {
    params = params || {};
    params.url = '/v3/web/myCoupon/shareCouponNo';
    return fetch(params);
  },
  //无券码时请求券详情
  couponDetail(params){
      params = params || {};
      params.method = 'post';
      params.url = '/v3/share/circle_of_friends/peer';
      return fetch(params);
  },
  getMarketCoupon(params){
    params = params || {};
    params.method = 'post';
    params.url = '/v2/web/trading_area/coupon';
    return fetch(params);
  },
	marketGoodCoupon(params){    	
	  params = params || {};
	  params.method = 'post';
	  params.url='/v2/web/CouponExpress/findCouponExpress';
	  return fetch(params);    
	},
	//券集市有定位
	marketGoodCouponPos(params){    	
	  params = params || {};
	  params.method = 'post';
	  params.url='/v2/web/trading_area/area_coupon';
	  return fetch(params);    
	},
	//首页有定位
	marketGoodCouponPosHome(params){    	
	  params = params || {};
	  params.method = 'post';
	  params.url='/v2/web/trading_area/query_area';
	  return fetch(params);    
	},
  //首页没有定位
	getHomeMchtListInfo(params){
	  params = params || {};
	  params.method = 'post';
	  params.url='/v2/web/trading_area/recommend';
	  return fetch(params);
	},
	  //好券速递查询挂单
	findSeqno(params){
	  params = params || {};
	  params.method = 'post';
	  params.url='/v2/web/CouponExpress'+'/'+params.couponId+'/'+params.mchtId;
	  return fetch(params);
	},
  // 获取热词
  getSearchRecord(params){
    params = params || {};
    params.method = 'get';
    params.url='/v2/web/search/findSearchRecord/' + params.type;
    return fetch(params);
  }
}
